
<template>
	<view>
		<uni-list>
			<uni-list-item  :key="item.id" v-for="item in list"  :note="item.name"  :show-extra-icon="true" :extra-icon="extraIcon" :show-switch="true" :title="item.text" @switchChange="switchChange(item)" :switch-checked="false">
		<</uni-list-item>
		</uni-list>
	</view>
</template>
 
<script>
import * as NoticeApi from '@/api/work/notice'	
	export default {
		components: {},
		data() {  
			return {
				list:[{id:"1",text:"哈哈"}],
				extraIcon: {
					color: '#4cd964',
					size: '22',
					type:'heart' //icon名
				}
			};
		},
		created() {
	     this.getList()
		},
		methods:{
			switchChange(item) {
				uni.showModal({
				    title: '提示',
				    content: '是否通过审核',
					cancelText:"不通过",
					confirmText:"通过",
				    success: function (res) {
				        if (res.confirm) {
							item.pass=2;
							NoticeApi.updatePost(item).then(res => {
							  uni.showToast({
							  	title:"审核成功"
							  })
							})
				        } else if (res.cancel) {
							item.pass=3;
				           NoticeApi.updatePost(item).then(res => {
							   uni.showToast({
							   	title:"审核失败"
							   })
				           })
				        }
				    }
				});
				this.getList()
			},
			getList () {
			  NoticeApi.selectPostList().then(res => {
			    this.list = res.list;
			  })
			}
		}
	};
</script>